<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<meta http-equiv="pragma" content="no-cache" />
	<link rel="stylesheet" href="/css/style.css" type="text/css"/>
	<script type="text/javascript" src="/js/jquery.js"></script>
	<script type="text/javascript" src="/js/util.js"></script>
</head>
<script type="text/javascript">
//////////////////////////////////////////////////////////////////////
////  email = "wenpin.qian@happyelements.com"                     ////
////  team = "Athene"                                             ////
////  warnings = "This is generated page,Do Not Modify!";         ////
////  tips = "Opera & IE not supported|Chrome & Safari sugguested"////
//////////////////////////////////////////////////////////////////////
window.returnValue=0;

$(document).ready(function() {
listselectors();
});

function addconstants() {
	var addconstantsUrl = "/constants/add/";
	var energeBoostPeriodValue = $("#energeBoostPeriod").val();
	if(!checkInteger("精力补充间隔(s)",energeBoostPeriodValue,false)) {
		return;
	}
	var energeBoostPeriodParam = "energeBoostPeriod=" + xparseInt(energeBoostPeriodValue);
		
	var energeBoostUnitValue = $("#energeBoostUnit").val();
	if(!checkInteger("单位补充精力点数",energeBoostUnitValue,false)) {
		return;
	}
	var energeBoostUnitParam = "energeBoostUnit=" + xparseInt(energeBoostUnitValue);
		
	var practiceDuration1Value = $("#practiceDuration1").val();
	if(!checkFloat("短时修炼时间（小時）",practiceDuration1Value,false)) {
		return;
	}
	var practiceDuration1Param = "practiceDuration1=" + xparseFloat(practiceDuration1Value);
		
	var practiceDuration2Value = $("#practiceDuration2").val();
	if(!checkInteger("中时修炼时间（小時）",practiceDuration2Value,false)) {
		return;
	}
	var practiceDuration2Param = "practiceDuration2=" + xparseInt(practiceDuration2Value);
		
	var practiceDuration3Value = $("#practiceDuration3").val();
	if(!checkInteger("长时种修炼时间（小時）",practiceDuration3Value,false)) {
		return;
	}
	var practiceDuration3Param = "practiceDuration3=" + xparseInt(practiceDuration3Value);
		
	var practiceSpeedExtraExpValue = $("#practiceSpeedExtraExp").val();
	if(!checkInteger("加速修炼附加经验百分比",practiceSpeedExtraExpValue,false)) {
		return;
	}
	var practiceSpeedExtraExpParam = "practiceSpeedExtraExp=" + xparseInt(practiceSpeedExtraExpValue);
		
	var practiceCostCoeff1Value = $("#practiceCostCoeff1").val();
	if(!checkFloat("短时修炼银币系数",practiceCostCoeff1Value,false)) {
		return;
	}
	var practiceCostCoeff1Param = "practiceCostCoeff1=" + xparseFloat(practiceCostCoeff1Value);
		
	var practiceCostCoeff2Value = $("#practiceCostCoeff2").val();
	if(!checkFloat("中时修炼银币系数",practiceCostCoeff2Value,false)) {
		return;
	}
	var practiceCostCoeff2Param = "practiceCostCoeff2=" + xparseFloat(practiceCostCoeff2Value);
		
	var practiceCostCoeff3Value = $("#practiceCostCoeff3").val();
	if(!checkFloat("长时修炼金币系数",practiceCostCoeff3Value,false)) {
		return;
	}
	var practiceCostCoeff3Param = "practiceCostCoeff3=" + xparseFloat(practiceCostCoeff3Value);
		
	var practiceSpeedCostValue = $("#practiceSpeedCost").val();
	if(!checkInteger("加速修炼金币数",practiceSpeedCostValue,false)) {
		return;
	}
	var practiceSpeedCostParam = "practiceSpeedCost=" + xparseInt(practiceSpeedCostValue);
		
	var practiceDirectlyFinishCostValue = $("#practiceDirectlyFinishCost").val();
	if(!checkInteger("立即完成金币数",practiceDirectlyFinishCostValue,false)) {
		return;
	}
	var practiceDirectlyFinishCostParam = "practiceDirectlyFinishCost=" + xparseInt(practiceDirectlyFinishCostValue);
		
	var practiceExpUnitCoeff1Value = $("#practiceExpUnitCoeff1").val();
	if(!checkInteger("短时修炼经验系数",practiceExpUnitCoeff1Value,false)) {
		return;
	}
	var practiceExpUnitCoeff1Param = "practiceExpUnitCoeff1=" + xparseInt(practiceExpUnitCoeff1Value);
		
	var practiceExpUnitCoeff2Value = $("#practiceExpUnitCoeff2").val();
	if(!checkInteger("中时修炼经验系数",practiceExpUnitCoeff2Value,false)) {
		return;
	}
	var practiceExpUnitCoeff2Param = "practiceExpUnitCoeff2=" + xparseInt(practiceExpUnitCoeff2Value);
		
	var practiceExpUnitCoeff3Value = $("#practiceExpUnitCoeff3").val();
	if(!checkInteger("长时修炼经验系数",practiceExpUnitCoeff3Value,false)) {
		return;
	}
	var practiceExpUnitCoeff3Param = "practiceExpUnitCoeff3=" + xparseInt(practiceExpUnitCoeff3Value);
		
	var practiceSpeedItemIdValue = $("#practiceSpeedItemId").val();
	
	var practiceSpeedItemIdParam = "practiceSpeedItemId=" + practiceSpeedItemIdValue;
		
	var versusItemIdValue = $("#versusItemId").val();
	
	var versusItemIdParam = "versusItemId=" + versusItemIdValue;
		
	var versusLevelLimitValue = $("#versusLevelLimit").val();
	if(!checkInteger("切磋等级下限",versusLevelLimitValue,false)) {
		return;
	}
	var versusLevelLimitParam = "versusLevelLimit=" + xparseInt(versusLevelLimitValue);
			
	$.ajax({
		   type: "POST",
		   url: addconstantsUrl,
		   data:   energeBoostPeriodParam +'&'+ energeBoostUnitParam +'&'+ practiceDuration1Param +'&'+ practiceDuration2Param +'&'+ practiceDuration3Param +'&'+ practiceSpeedExtraExpParam +'&'+ practiceCostCoeff1Param +'&'+ practiceCostCoeff2Param +'&'+ practiceCostCoeff3Param +'&'+ practiceSpeedCostParam +'&'+ practiceDirectlyFinishCostParam +'&'+ practiceExpUnitCoeff1Param +'&'+ practiceExpUnitCoeff2Param +'&'+ practiceExpUnitCoeff3Param +'&'+ practiceSpeedItemIdParam +'&'+ versusItemIdParam +'&'+ versusLevelLimitParam ,
		   dataType: "json",
		   success: function(data) {
			   if(data.code > 0) {
			       window.returnValue=1;
			       beforeWindowClose();
				   window.close();
			   }else {
				  errDialog(data.message);
			   }
		   }
	});
}

function listselectors() {
var getItemSelectorUrl = "/special/Item/getList/";
$.ajax({
		   type: "GET",
		   url: getItemSelectorUrl,
		   data: "",
		   dataType: "json",
		   success: function(data) {
			   if(data.code > 0) {
				   selectpracticeSpeedItemId(s2json(data.result));
			   }else {
				   errDialog(data.message);
			   }
		   }
	});
var getItemSelectorUrl = "/special/Item/getList/";
$.ajax({
		   type: "GET",
		   url: getItemSelectorUrl,
		   data: "",
		   dataType: "json",
		   success: function(data) {
			   if(data.code > 0) {
				   selectversusItemId(s2json(data.result));
			   }else {
				   errDialog(data.message);
			   }
		   }
	});
}

function selectpracticeSpeedItemId(options) {
	var optionHTML = "";
	for(var i in options) {
		optionHTML = optionHTML + "<option value='"+ options[i][0] +"'>" + options[i][1] + "</option>\n";
	}
	$("#practiceSpeedItemId").html(optionHTML);
}
function selectversusItemId(options) {
	var optionHTML = "";
	for(var i in options) {
		optionHTML = optionHTML + "<option value='"+ options[i][0] +"'>" + options[i][1] + "</option>\n";
	}
	$("#versusItemId").html(optionHTML);
}

function openResource(fieldname,dependfield) {
	var param = "";
	if(dependfield!="") {
		param = $("#" + dependfield).val()
		if(param == null || param == "") {
			alert("你先把【" + $("#lbl_" + dependfield).html() + "】填了再上传");
			return;
		}
	}
	resourceDialog("constants",$("#" + fieldname).val(),param,function(result) {
		if(result != undefined && result != "") {
			$("#" + fieldname).val(result);
		}
	});
}

function beforeWindowClose() {
	if(window.returnCallback) {
		window.returnCallback(window.returnValue);
	}
	window.onbeforeunload = null;
	return true;
}

</script>
<body onunload="beforeWindowClose()">
	<div class="addarea">
	<form action="/constants/add" method="post">
		<table>
			<tbody>				
					<tr>					<td>
						<label for="energeBoostPeriod" id="lbl_energeBoostPeriod">精力补充间隔(s)</label>
													<input type="text" id="energeBoostPeriod" name="energeBoostPeriod" /><span class="tips">[整数]</span>
											</td>
									
										<td>
						<label for="energeBoostUnit" id="lbl_energeBoostUnit">单位补充精力点数</label>
													<input type="text" id="energeBoostUnit" name="energeBoostUnit" /><span class="tips">[整数]</span>
											</td>
					</tr>				
					<tr>					<td>
						<label for="practiceDuration1" id="lbl_practiceDuration1">短时修炼时间（小時）</label>
													<input type="text" id="practiceDuration1" name="practiceDuration1" /><span class="tips">[小数]</span>
											</td>
									
										<td>
						<label for="practiceDuration2" id="lbl_practiceDuration2">中时修炼时间（小時）</label>
													<input type="text" id="practiceDuration2" name="practiceDuration2" /><span class="tips">[整数]</span>
											</td>
					</tr>				
					<tr>					<td>
						<label for="practiceDuration3" id="lbl_practiceDuration3">长时种修炼时间（小時）</label>
													<input type="text" id="practiceDuration3" name="practiceDuration3" /><span class="tips">[整数]</span>
											</td>
									
										<td>
						<label for="practiceSpeedExtraExp" id="lbl_practiceSpeedExtraExp">加速修炼附加经验百分比</label>
													<input type="text" id="practiceSpeedExtraExp" name="practiceSpeedExtraExp" /><span class="tips">[整数]</span>
											</td>
					</tr>				
					<tr>					<td>
						<label for="practiceCostCoeff1" id="lbl_practiceCostCoeff1">短时修炼银币系数</label>
													<input type="text" id="practiceCostCoeff1" name="practiceCostCoeff1" /><span class="tips">[小数]</span>
											</td>
									
										<td>
						<label for="practiceCostCoeff2" id="lbl_practiceCostCoeff2">中时修炼银币系数</label>
													<input type="text" id="practiceCostCoeff2" name="practiceCostCoeff2" /><span class="tips">[小数]</span>
											</td>
					</tr>				
					<tr>					<td>
						<label for="practiceCostCoeff3" id="lbl_practiceCostCoeff3">长时修炼金币系数</label>
													<input type="text" id="practiceCostCoeff3" name="practiceCostCoeff3" /><span class="tips">[小数]</span>
											</td>
									
										<td>
						<label for="practiceSpeedCost" id="lbl_practiceSpeedCost">加速修炼金币数</label>
													<input type="text" id="practiceSpeedCost" name="practiceSpeedCost" /><span class="tips">[整数]</span>
											</td>
					</tr>				
					<tr>					<td>
						<label for="practiceDirectlyFinishCost" id="lbl_practiceDirectlyFinishCost">立即完成金币数</label>
													<input type="text" id="practiceDirectlyFinishCost" name="practiceDirectlyFinishCost" /><span class="tips">[整数]</span>
											</td>
									
										<td>
						<label for="practiceExpUnitCoeff1" id="lbl_practiceExpUnitCoeff1">短时修炼经验系数</label>
													<input type="text" id="practiceExpUnitCoeff1" name="practiceExpUnitCoeff1" /><span class="tips">[整数]</span>
											</td>
					</tr>				
					<tr>					<td>
						<label for="practiceExpUnitCoeff2" id="lbl_practiceExpUnitCoeff2">中时修炼经验系数</label>
													<input type="text" id="practiceExpUnitCoeff2" name="practiceExpUnitCoeff2" /><span class="tips">[整数]</span>
											</td>
									
										<td>
						<label for="practiceExpUnitCoeff3" id="lbl_practiceExpUnitCoeff3">长时修炼经验系数</label>
													<input type="text" id="practiceExpUnitCoeff3" name="practiceExpUnitCoeff3" /><span class="tips">[整数]</span>
											</td>
					</tr>				
					<tr>					<td>
						<label for="practiceSpeedItemId" id="lbl_practiceSpeedItemId">修炼加速道具ID</label>
													<select id="practiceSpeedItemId" name="practiceSpeedItemId">
							</select>
											</td>
									
										<td>
						<label for="versusItemId" id="lbl_versusItemId">切磋道具ID</label>
													<select id="versusItemId" name="versusItemId">
							</select>
											</td>
					</tr>				
					<tr>					<td>
						<label for="versusLevelLimit" id="lbl_versusLevelLimit">切磋等级下限</label>
													<input type="text" id="versusLevelLimit" name="versusLevelLimit" /><span class="tips">[整数]</span>
											</td>
												</tbody>
		</table>
		<input type="button" onclick="addconstants()" value="添加"/>
	</form>
	</div>
</body>